package com.itheima.edu.map.hashMap;

import java.util.Comparator;
import java.util.HashMap;
import java.util.TreeMap;

public class TreeMapStudentAdmin {
    public static void main(String[] args) {
        TreeMap<Student, String> stuTm = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result = o1.getAge().compareTo(o2.getAge());
                return result;
            }
        });
        Student s1 = new Student("lisi", "24");
        Student s2 = new Student("zhangsan", "23");
        Student s3 = new Student("wangwu", "25");

        stuTm.put(s1, "南京");
        stuTm.put(s2, "北京");
        stuTm.put(s3, "上海");

        stuTm.forEach((Student s,String address)-> System.out.println(s+"---"+address));
    }
}
